package com.itheima.Work01;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.time.Period;
import java.util.Properties;

public class work05 {
    public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        InputStream stream = systemClassLoader.getResourceAsStream("bean.properties");
        //创建集合
        Properties  prop = new Properties();
        //获取输入流
        //把流中的数据添加到集合
        prop.load(stream);
        String className = prop.getProperty("className");
        String methodName = prop.getProperty("methodName");
        //获取字节码对象
        Class clazz = Class.forName(className);
        Object obj = clazz.getDeclaredConstructor().newInstance();
        Method method = clazz.getDeclaredMethod(methodName);
        method.invoke(obj);
    }
}
